package com.zmc.order.controller;

import java.util.List;

import com.zmc.common.utils.poi.ExcelUtil;
import com.zmc.order.infrastructure.bean.query.OrderSettingQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.zmc.order.infrastructure.entity.OrderSettingEntity;
import com.zmc.order.infrastructure.service.OrderSettingService;
import com.zmc.common.utils.PageUtils;
import com.zmc.common.utils.R;

import javax.servlet.http.HttpServletResponse;


/**
 * 订单配置信息
 *
 * @author zmc
 * @email 
 * @date 2024-10-09 14:52:02
 */
@RestController
@RequestMapping("/setting")
public class OrderSettingController {
    @Autowired
    private OrderSettingService orderSettingService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public R list(@RequestBody OrderSettingQuery query){
        return R.page(orderSettingService.queryPage(query));
    }

    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderSettingQuery query) {
        List<OrderSettingEntity> list = orderSettingService.selectList(query);
        ExcelUtil<OrderSettingEntity> util = new ExcelUtil<>(OrderSettingEntity.class);
        util.exportExcel(response, list, "订单配置信息");
    }


    /**
     * 信息
     */
    @PostMapping("/info")
    public R info(@RequestBody OrderSettingEntity orderSetting){
        return R.ok(orderSettingService.getById(orderSetting.getId()));
    }

    /**
     * 保存
     */
    @PostMapping("/add")
    public R save(@RequestBody OrderSettingEntity orderSetting){
		orderSettingService.save(orderSetting);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody OrderSettingEntity orderSetting){
		orderSettingService.updateById(orderSetting);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R remove(@RequestBody OrderSettingEntity orderSetting){
		orderSettingService.removeById(orderSetting.getId());
        return R.ok();
    }

}
